package org.common.utils.fasttest;

import java.util.Random;

/**
 * @author zhouzhibing
 * @date 2024/10/23
 */
public class TestRandom {

    static final int COUNT = 10000000;

    static final int MIN = 10 , MAX = 11;
    public static void test() {
//        testMathRandom();
//        testRandom();

        Random random = new Random();
        for (int i = 0; i < 100; i++) {
            int randomIntInRange = random.nextInt((MAX - MIN) + 1) + MIN;
            System.out.println(randomIntInRange);
        }
    }

    private static void testMathRandom() {
        Test.doHandler("testMathRandom"  , COUNT , 10 , (index) -> {
            // 生成一个 0.0 到 1.0 之间的随机 double 类型浮点数
            double randomDouble = Math.random();
            // 要生成一个特定范围内的随机整数，例如 1 到 100
            int min = MIN;
            int max = MAX;
            int randomInRange = min + (int)(Math.random() * ((max - min) + 1));
        });
    }


    private static void testRandom() {

        Random random = new Random();
        Test.doHandler("testRandom"  , COUNT , 10 , (index) -> {
            // 生成一个随机整数
//            int randomInt = random.nextInt();
            // 生成一个 0 到 bound-1 之间的随机整数
//            int bound = 100;
            int randomIntInRange = random.nextInt(MAX - MIN) + MIN + 1;
        });
    }

}
